<?php

namespace App\Services\Account;

use Illuminate\Database\Eloquent\Relations\HasMany;

class AccountApples extends AccountAbstract
{
    protected function account(): HasMany
    {
        return $this->user->userApples();
    }

    /*---------- plus --------------------------------------------------------------------------------------------------*/

    public function plusOwnTreeProduceApples($apples,$data = [])
	{
		$apples = big_decimal($apples);
		$this->record($apples, 'own_tree_produce_apples', '我的苹果树产出', $data);
	}

	public function plusTreeProduceApples($apples, $number,$data = [])
	{

		$apples = big_decimal($apples);
		$this->record($apples, "{$number}_tree_produce_apples", "{$number}区苹果树产出", $data);
	}

	public function plusGardenProduceApples($apples, $data = [])
	{
		$apples = big_decimal($apples);
		$this->record($apples, 'garden_produce_apples', '变异树产出', $data);
	}

	public function plusGetApples($apples, $data = [],$name)
	{
		$apples = big_decimal($apples);
		$this->record($apples, 'get_apples', '收到'.$name.'的赠送', $data);
	}

	public function plusPresentApples($money, $data = [])
	{
		$money = big_decimal($money);
		$this->record($money, 'present_apples', '平台赠送小苹果', $data);
	}



	/*---------- minus -------------------------------------------------------------------------------------------------*/

	public function minusGiftApples($apples, $data = [],$name)
	{
		$apples = big_decimal($apples)->multipliedBy(-1);
		$this->record($apples, 'gift_apples', '赠送给'.$name, $data);
	}

	public function minusApplesExchangeBalances($apples, $data = [])
	{
		$apples = big_decimal($apples)->multipliedBy(-1);
		$this->record($apples, 'apples_exchange_balances', '苹果兑换红包', $data);
	}

	public function minusAppleExchangeTrees($apples, $data = [])
	{
		$apples = big_decimal($apples)->multipliedBy(-1);
		$this->record($apples, 'apple_exchange_trees', '苹果兑换变异树', $data);
	}

	public function minusAppleExchangeOrders($apples, $data = [])
	{
		$apples = big_decimal($apples)->multipliedBy(-1);
		$this->record($apples, 'apple_exchange_order', '苹果兑换商品', $data);
	}
	

	public function minusSystemRecallApples($apples, $data = [])
	{
		$apples = big_decimal($apples)->multipliedBy(-1);
		$this->record($apples, 'system_recall', '系统回收', $data);
	}


	
}
